package com.ebring.shareEducation.utils;

import org.apache.http.client.HttpClient;

import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;

import javax.servlet.http.HttpServletRequest;

public class HttpClientC {

    private static HttpClient client = null;
    static {
        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
        cm.setMaxTotal(128);
        cm.setDefaultMaxPerRoute(128);
        client = HttpClients.custom().setConnectionManager(cm).build();
    }

    //根据request获取请求的url
    public StringBuffer getUrlToRequest(HttpServletRequest request) {
        StringBuffer url=request.getRequestURL();//获取请求的url(http://localhost:8080/switch/getStudentInfoByName)
        String[] splitArr=url.toString().split("/");
        String appName=splitArr[3];//项目名称
        String ipReport=splitArr[2];//项目ip:report
        String resultStr=url.toString().replaceAll(appName,"").replaceAll(ipReport, ""+":"+"");
        return new StringBuffer(resultStr);
    }


}
